home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / gcc / ixemul-4.lha / ixemul-41.4 / include / user.h < prev    next >
C/C++ Source or Header  |  1995-05-17  |  8KB  |  256 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20.  
  21. #include <sys/time.h>
  22. #include <sys/resource.h>
  23. #include <setjmp.h>
  24.  
  25. /* internal structure used by malloc(), kmalloc() and friends */
  26. #if 0
  27. struct malloc_data {
  28.   struct Remember    *md_key;
  29.   unsigned int        md_malloc_sbrk_used;
  30.   struct mhead        *md_nextf[30];
  31.   char            md_busy[30];
  32.   int            md_gotpool;
  33. };
  34. #else
  35. struct malloc_data {
  36.   struct MinList    md_list;
  37.   unsigned int        md_malloc_sbrk_used;
  38. };
  39. #endif
  40.  
  41. /*
  42.  * One structure allocated per session.
  43.  */
  44. struct    session {
  45.     int    s_count;        /* ref cnt; pgrps in session */
  46.     struct    proc *s_leader;        /* session leader */
  47.     struct    vnode *s_ttyvp;        /* vnode of controlling terminal */
  48.     struct    tty *s_ttyp;        /* controlling terminal */
  49.     char    s_login[MAXLOGNAME];    /* setlogin() name */
  50. };
  51.  
  52. /*
  53.  * One structure allocated per process group.
  54.  */
  55. struct    pgrp {
  56.     struct    pgrp *pg_hforw;        /* forward link in hash bucket */
  57.     struct    proc *pg_mem;        /* pointer to pgrp members */
  58.     struct    session *pg_session;    /* pointer to session */
  59.     pid_t    pg_id;            /* pgrp id */
  60.     int    pg_jobc;    /* # procs qualifying pgrp for job control */
  61. };
  62.  
  63. /*
  64.  * Per process structure
  65.  */
  66.  
  67. struct user {
  68.     /* both a magic cookie and a way to get at the library base thru u */
  69.     struct  ixemul_base *u_ixbase;
  70.  
  71. /* 1.3 - signal management */
  72.     sig_t    u_signal[NSIG];        /* disposition of signals */
  73.     int    u_sigmask[NSIG];    /* signals to be blocked */
  74.     sigset_t    u_sigonstack;        /* signals to take on sigstack */
  75.     sigset_t    u_sigintr;        /* signals that interrupt syscalls */
  76.     sigset_t    u_oldmask;        /* saved mask from before sigpause */
  77.     struct    sigstack u_sigstack;    /* sp & on stack state variable */
  78. #define    u_onstack    u_sigstack.ss_onstack
  79. #define    u_sigsp        u_sigstack.ss_sp
  80.     int    u_sig;            /* for core dump/debugger XXX */
  81.     int    u_code;            /* for core dump/debugger XXX */
  82.     
  83.     int    p_flag;            /* process flags, as necessary.. */
  84.     char    p_stat;
  85.     char    p_xstat;        /* what does this do... ? */
  86.     char    p_cursig;
  87.     sigset_t    p_sig;            /* signals pending to this process */
  88.     sigset_t    p_sigmask;        /* current signal mask */
  89.     sigset_t    p_sigignore;        /* signals being ignored */
  90.     sigset_t    p_sigcatch;        /* signals being caught by user */
  91.  
  92.     caddr_t p_wchan;        /* event process is awaiting */
  93.  
  94.  
  95. /* 1.4 - descriptor management (for shared library version) */
  96.     struct    file *u_ofile[NOFILE];    /* file structures for open files */
  97.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  98.     int    u_lastfile;        /* high-water mark of u_ofile */
  99. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  100.     short    u_cmask;        /* mask for file creation */
  101.  
  102. /* 1.5 - timing and statistics */
  103.     struct    rusage u_ru;        /* stats for this proc */
  104.     struct    rusage u_cru;        /* sum of stats for reaped children */
  105.     struct    itimerval u_timer[3];
  106.     struct    timeval u_start;
  107.     short    u_acflag;
  108.  
  109.     struct uprof {            /* profile arguments */
  110.         short    *pr_base;    /* buffer base */
  111.         unsigned pr_size;    /* buffer size */
  112.         unsigned pr_off;    /* pc offset */
  113.         unsigned pr_scale;    /* pc scaling */
  114.     } u_prof;
  115.  
  116. /* 1.6 - resource controls */
  117.     struct    rlimit u_rlimit[RLIM_NLIMITS];
  118.  
  119. /* amiga specific stuff */
  120.     struct malloc_data    u_md;
  121.     
  122.     struct MsgPort        *u_sync_mp;    /* PA_SIGNAL message port */
  123.     struct timerequest     *u_time_req;
  124.     int            *u_errno;
  125.     BPTR            u_startup_cd;
  126.     
  127.     int            u_ringring;    /* used in sleep.c and usleep.c */
  128.  
  129.     char            ***u_environ;
  130.  
  131.     /* used to handle amigados signals. see SIGMSG  */
  132.         u_int            u_lastrcvsig;
  133.         char            u_sleep_sig;
  134.         
  135.         /* c-startup stuff */
  136.         jmp_buf            u_jmp_buf;
  137.         char             *u_argline;
  138.         u_int            u_arglinelen;
  139.         int            u_expand_cmd_line;
  140.  
  141.     struct atexit        *u_atexit;
  142.     
  143.     char            u_getenv_buf[255];
  144.     
  145.     UBYTE            u_otask_flags;
  146.     void            (*u_olaunch)();
  147.     APTR            u_otrap_code;
  148.     APTR            u_otrap_data;
  149.     struct Interrupt    u_itimerint;    /* 1 interrupt / task */
  150.  
  151.     int            p_pgrp;        /* process group */
  152.  
  153.     char            *u_strtok_last;    /* moved with 37.8 */
  154.     
  155.     /* vfork() support */
  156.     struct MinList        p_zombies;    /* list of death messages */
  157.     int            p_zombie_sig;    /* signal to set when a child died */
  158.     struct Process        *p_pptr;    /* parent */
  159.     struct Process        *p_cptr;    /* last recently created child */
  160.     struct Process        *p_osptr;    /* older sybling */
  161.     struct Process        *p_ysptr;    /* younger sybling */
  162.     struct vfork_msg    *p_vfork_msg;
  163.  
  164. #if 0
  165.     /* moved to global space (ix_async_mp) */
  166.     struct MsgPort        *u_async_mp;    /* PA_SOFTINT message port */
  167. #else
  168.     long            u_rese0;
  169. #endif
  170.     void            (*u_oswitch)();
  171.     
  172.     /* stdio support comes here */
  173.     char            u_tmpnam_buf[MAXPATHLEN]; /* quite large.. */
  174. #include <glue.h>
  175.     struct glue        u_sglue;
  176.     /* the 3 `standard' FILE pointers (!) are here */
  177.     void            *u_sF[3];
  178.  
  179.     /* vfork() support #2 */
  180.     void            *u_save_sp;    /* when vfork'd, this is the `real' sp */
  181.     jmp_buf            u_vfork_frame;    /* for the parent in vfork () */
  182.     u_int            u_mini_stack[1000]; /* 4K stack while in vfork () */
  183.  
  184.     /* stack watcher. When usp < u_red_zone && ix.ix_watch_stack -> SIGSEGV */
  185.     void            *u_red_zone;
  186.  
  187.     /* base relative support. This even works for pure programs ! */
  188.     u_int            u_a4;
  189.     
  190.     /* currently there's just 1, meaning don't trace me */
  191.     u_int            u_trace_flags;
  192.     
  193.     /* this is for getmntinfo() */
  194.     struct statfs        *u_mntbuf;
  195.     int            u_mntsize;
  196.     long            u_bufsize;
  197.     
  198.     /* this is for SIGWINCH support. */
  199.     struct IOStdReq        *u_idev_req;
  200.     struct Window        *u_window;    /* the watched window */
  201.     struct Interrupt    u_idev_int;
  202.  
  203.     /* for `ps' (or dump as it's called for now.. ) */
  204.     char            *p_wmesg;
  205.     
  206.     /* new support for `real' process groups, control ttys etc.. */
  207.     struct user        *p_pgrpnxt;
  208.     struct pgrp        *p_pgrpptr;
  209.     struct Process        *p_exec_proc;    /* to get back to struct Process */
  210.     
  211.     /* to be able to switch memory lists on the fly, as required when vfork'd
  212.        processes are supposed to allocate memory from their parents pool until
  213.        they detach. */
  214.     struct malloc_data    *u_mdp;
  215.     
  216.     /* data needed for network support */
  217.     int            u_sigurg;
  218.     int            u_sigio;
  219.     void            *u_InetBase;
  220.     
  221. };
  222.  
  223. /* flag codes */
  224. #define    SLOAD    0x0000001    /* in core */
  225. #define    SSYS    0x0000002    /* swapper or pager process */
  226. #define    SLOCK    0x0000004    /* process being swapped out */
  227. #define    SSWAP    0x0000008    /* save area flag */
  228. #define    STRC    0x0000010    /* process is being traced */
  229. #define    SWTED    0x0000020    /* parent has been told that this process stopped */
  230. #define    SULOCK    0x0000040    /* user settable lock in core */
  231. #define    SNOCLDSTOP    0x0000080    /* tc_Launch has to take a signal next time */
  232. #define    SFREEA4    0x0000100    /* we allocated memory for a4, free it */
  233. #define    SOMASK    0x0000200    /* restore old mask after taking signal */
  234. #define    SWEXIT    0x0000400    /* working on exiting */
  235. #define    SPHYSIO    0x0000800    /* doing physical i/o (bio.c) */
  236. #define    SVFORK    0x0001000    /* process resulted from vfork() */
  237. #define    SVFDONE    0x0002000    /* another vfork flag */
  238. #define    SNOVM    0x0004000    /* no vm, parent in a vfork() */
  239. #define    SPAGI    0x0008000    /* init data space on demand, from inode */
  240. #define    SSEQL    0x0010000    /* user warned of sequential vm behavior */
  241. #define    SUANOM    0x0020000    /* user warned of random vm behavior */
  242. #define    STIMO    0x0040000    /* timing out during sleep */
  243. #define    SORPHAN    0x0080000    /* process is orphaned (can't be ^Z'ed) */
  244. #define    STRACNG    0x0100000    /* process is tracing another process */
  245. #define    SOWEUPC    0x0200000    /* owe process an addupc() call at next ast */
  246. #define    SSEL    0x0400000    /* selecting; wakeup/waiting danger */
  247. #define    SLOGIN    0x0800000    /* a login process (legit child of init) */
  248.  
  249. /* stat codes */
  250. #define    SSLEEP    1        /* awaiting an event */
  251. #define    SWAIT    2        /* (abandoned state) */
  252. #define    SRUN    3        /* running */
  253. #define    SIDL    4        /* intermediate state in process creation */
  254. #define    SZOMB    5        /* has exited, waiting for parent to pick up status */
  255. #define    SSTOP    6        /* stopped */
  256.